# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.
#
# from AUR - adapted to you style
#
# Old Contributor: Lex Black <autumn-wind@web.de>

pkgname=gsad
pkgver=24.3.0
pkgrel=1
pkgdesc='Greenbone Security Assistant HTTP Server - The server talking to the Greenbone Vulnerability Management daemon (gvmd).'
arch=('x86_64' 'aarch64')
url='https://github.com/greenbone/gsad'
license=('AGPL-3.0-only')
depends=('gvmd' 'gvm-libs' 'gnutls' 'libgcrypt' 'libmicrohttpd' 'libglib-2.0.so'
         'libxml2.so' 'zlib')
makedepends=('cmake' 'xmltoman')
optdepends=('logrotate: for rotating logs')
source=("https://github.com/greenbone/gsad/archive/refs/tags/v$pkgver.tar.gz"
        '0001-libgcrypt-config.patch'
        '0002-fix-unit-path.patch')
sha512sums=('6c42ee9db41b3705a527431e3d191d06bec8a72bcc0238e202d4cfc993a8b762f5af8ff898f05d3502126406d753122e2a82ff0ef18349f0d4343002c348a5e0'
            'a063e3caccb3a24f3bc164cb03e8ff27cdfbd5f2275158a00a6a1b49d920a99d663e0616d344b3dee3e640329b7e74667861c7c24bc5fd6f3d51ab4ec4c7c7b8'
            '3d86dfd288dcf1ab91454c0fefcb33e2bf9cdc20638804fd524ebee5ff5783a21c67e9d6b5b575a2d009c2f97828d3866513b00d02d18665ecf3f1ca91c99c41')

prepare() {
  cd "$pkgname-$pkgver"

  sed -i '/-Werror/d' CMakeLists.txt
}

build() {
  cmake \
    -B build \
    -S "$pkgname-$pkgver" \
    -DCMAKE_BUILD_TYPE=None \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
    -DSBINDIR=/usr/bin \
    -DLIBDIR=/usr/lib \
    -DSYSCONFDIR=/etc \
    -DLOCALSTATEDIR=/var \
    -DGVMD_RUN_DIR=/run/gvmd \
    -DGSAD_RUN_DIR=/run/gsad

  make -C build
}

package() {
  make DESTDIR="$pkgdir" -C build install
}

